package com.ddstation.crm.institution.mapper;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

import com.ddstation.crm.institution.entity.DtHealthManageInstitutionBuyAccountEntity;
import com.ddstation.crm.institution.entity.DtHealthManageInstitutionDoctorEntity;
import com.ddstation.crm.institution.model.UserAccountModel;


/**
 * dt_health_manage_institution_doctor 健康管理机构 & 健康管理师
 * @author zhangdifeng
 * @date 2017年7月11日
 */
public interface DtHealthManageInstitutionDoctorMapper {
	public DtHealthManageInstitutionDoctorEntity selectByPK(
            @Param("doctorId") Integer doctorId,
            @Param("institutionId") String institutionId);
	public DtHealthManageInstitutionDoctorEntity selectByLoginUser(DtHealthManageInstitutionDoctorEntity entity);
	public List<DtHealthManageInstitutionDoctorEntity> select(DtHealthManageInstitutionDoctorEntity entity);
	public List<DtHealthManageInstitutionDoctorEntity> selectInstitution(DtHealthManageInstitutionDoctorEntity entity);
	public List<DtHealthManageInstitutionDoctorEntity> selectInstitutionWithMainDoctor(DtHealthManageInstitutionDoctorEntity entity);
	public int insert(DtHealthManageInstitutionDoctorEntity entity);
	public int update(DtHealthManageInstitutionDoctorEntity entity);
	public int delete(@Param("doctorId") Integer doctorId,
                      @Param("institutionId") String institutionId);
	
//	public DtHealthManageInstitutionEntity selectInstitution(String id);
	public List<UserAccountModel> selectInstitutionDoctor(String id);
	public List<Map<String, Object>> selectAccountType(String id);
	public int selectAccountCnt(String id);
	public UserAccountModel selectAccountByLoginUser(@Param("loginUser") String loginUser);
	public Integer selectMinBuyAccount(String id, Integer accounttypeId);
//	public DtHealthManageInstitutionBuyAccountEntity selectInstitutionBuyAccount(Integer id);
	public DtHealthManageInstitutionBuyAccountEntity selectInstitutionBuyAccountByDoctorId(String doctorId, String institutionId);
	public List<DtHealthManageInstitutionBuyAccountEntity> selectInstitutionBuyAccountByDoctorId2(@Param("doctorId") int doctorId);
	/**
	 * 检索机构的失效日期
	 * @param institutionArray
	 * @return
	 */
	public List<DtHealthManageInstitutionBuyAccountEntity> selectInstitutionEndDt(@Param("institutionArray") List<String> institutionArray);
	public Integer insertBuyAccount(DtHealthManageInstitutionBuyAccountEntity entity);
	public Integer updateBuyAccount(@Param("id") Integer id, @Param("doctorId") String doctorId);
	public Integer removeBuyAccount(@Param("doctorId") String doctorId, @Param("institutionId") String institutionId);
//	public int insertStaff(DtInvsOrganizationStructureStaffEntity entity);
	
	public List<Integer> selectDoctorList(@Param("institutionId") String institutionId);
	
	/**
	 * 医生是否在SaaS平台就职
	 * @param doctorId
	 * @return
	 */
	public boolean isWorkOnSaas(@Param("doctorId") int doctorId);
	/**
	 * 根据登录名获取信息
	 * @param loginUser
	 * @return
	 */
	public UserAccountModel selectLoginUser(@Param("loginUser") String loginUser);

	public void insertForInvs(DtHealthManageInstitutionDoctorEntity entity);
}
